import {
  CreatorCreateDto,
  CreatorFindDto,
  CreatorQueryDto,
  CreatorRemoveDto,
  CreatorUpdateDto,
} from '@/dtos';
import { CreatorService } from '@/services/creator.service';
import { ok } from '@/utils';
import { Body, Controller, Delete, Patch, Post, Query } from '@nestjs/common';
import { BaseController } from './base.controller';

@Controller('creator')
export class CreatorController extends BaseController {
  constructor(private readonly creatorService: CreatorService) {
    super();
  }

  @Post('admin/query')
  async query(@Body() dto: CreatorQueryDto) {
    return ok(await this.creatorService.query(dto));
  }

  @Post('admin/find')
  async find(@Body() dto: CreatorFindDto) {
    return ok(await this.creatorService.findOne(dto.where, dto.select));
  }

  @Post('admin/create')
  async create(@Body() dto: CreatorCreateDto) {
    return ok(await this.creatorService.create(dto.data));
  }

  @Patch('admin/update')
  async update(@Body() dto: CreatorUpdateDto) {
    return ok(await this.creatorService.update(dto));
  }

  @Delete('admin/remove')
  async remove(@Query() dto: CreatorRemoveDto) {
    return ok(await this.creatorService.remove(dto));
  }
}
